package com.jinlejia.erp.ui.new_house.house;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import android.os.Bundle;
import android.view.View;

import com.jinlejia.erp.R;
import com.jinlejia.erp.common.WrapContentLinearLayoutManager;
import com.jinlejia.erp.databinding.ActivityHouseIntroduceBinding;
import com.jinlejia.erp.ui.new_house.adapter.HouseIntroduceAdapter;

import org.simple.eventbus.EventBus;
import org.simple.eventbus.Subscriber;

import java.util.ArrayList;
import java.util.Map;

/***
 * 楼盘介绍Activity
 */
public class HouseIntroduceActivity extends AppCompatActivity {
    private ActivityHouseIntroduceBinding binding;
    private HouseIntroduceAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this,R.layout.activity_house_introduce);
        binding.setEvent(this);
        EventBus.getDefault().registerSticky(this);

        binding.recyclerview.setHasFixedSize(true);
        binding.recyclerview.setLayoutManager(new WrapContentLinearLayoutManager(this));
        adapter = new HouseIntroduceAdapter(new ArrayList<>());
        binding.recyclerview.setAdapter(adapter);
    }

    @Subscriber(tag = "TAG_HOUSEINTRODUCE_LIST")
    public void getHouseIntroduce(ArrayList<Map<String, Object>> dataList) {
        EventBus.getDefault().removeStickyEvent(dataList.getClass(), "TAG_HOUSEINTRODUCE_LIST");
        adapter.setData(dataList);
        adapter.notifyDataSetChanged();
    }

    public void onClick(View view){
        finish();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}